export const formatNum =  (val, base = 100000000, unit = '亿') => {
  if (val && val.toString().indexOf('%')>=0) {
    return val
  }
  val = parseInt(val, 10)
  if (val == null || isNaN(val)) return 0
  if (val > base) {
    return (val / base).toFixed(1) + unit
  }
  return thousandBitSeparator(val)
}
export function thousandBitSeparator(num) {
  let result = []
  let counter = 0
  num = (num || 0).toString().split('')
  for (var i = num.length - 1; i >= 0; i--) {
    counter++
    result.unshift(num[i])
    if (!(counter % 3) && i !== 0) {
      result.unshift(',')
    }
  }
  return result.join('')
}

export function formatDataContent (num) {
  return num > 0 ? formatNum(num) : '--'
}